<template>
  <div class="package-wrap" style="padding-top: 50px">
    <van-nav-bar
      title="礼包专区"
      left-arrow
      fixed
      @click-left="$router.go(-1)"
    />

    <van-list
      v-model="loading"
      :finished="finished"
      finished-text="没有更多了"
      @load="fetch"
    >
    <div v-for="(item,index) in list" :key="index">
      <van-card
        :price="item.price"
        :title="item.title"
        :thumb="item.avatar"
        :currency="'专属券 ： '"
      >
      <div slot="footer">
        <van-button size="mini" @click="$router.push({name:'storeMinePackageDetails',params:{ store_id: store_id, data : item }})"  type="info">查看详情</van-button>
      </div>
      </van-card>
    </div>
     </van-list>
  </div>
</template>
<script>
import axios from 'axios'
export default {
  name:'package',
  props: ['store_id'],
  data(){
    return {
      list:[],
      page: null,
      loading: true,
      finished: false
    }
  },
  methods:{
    async fetch(){
      let params = {
        token: sessionStorage.getItem('token'),
        page: this.page + 1 || 1
      }
      const res = await axios.get(`/api/store/admin/tera/list`,params)
      this.list = res.data.data.data;
      this.page = res.data.data.current_page;
      this.loading = !1;
      if(this.page == res.data.data.last_page) {
        this.loading = !1;
        this.finished = !0
      }
    }
  },
  created() {
    this.fetch();
  },
}
</script>
